Gets details for the current user.
Returns the user info for the currently authenticated user
Method
/API2/access/getMe
- API Section: /API2/access
- API Version: 2.0
- From Release: 2020.0
- Usage: REST API only via POST actions.
- Usage by:
- Enterprise Admin
- Domain Admin
- Pro
- Analyst
- Viewer
- Basic
Method Signature
Input Parameters
There are no input parameters required for this method
Output Response
Successful Result Code
200
Response Type
Description of Response Type
The user object contains all relevant meta-data for the user.
Notes
Use this method to extract details for the account running the API calls
Examples
This example demonstrates how to authenticate a user from JavaScript.
// URL of the Pyramid installation and the path to the API 2.0 REST methods
var pyramidURL = "http://mysite.com/api2/";
// step 1: authenticate user account and get token
// NOTE: callApi method is a generic REST method shown below.
let token = callApi("auth/authenticateUser",{
"data":{
"userName":"aUser",
"password":"abc123!"
}
},false);
log("got token "+token);
// step 2: get the current user's ID
let currentUser= callApi("access/getMe",
{"auth": token}
);
// step3: get the user's ID from the response
let userId = currentUser.data[0];
// ##### optional generic login method for debugging ##############
function log(msg){
document.write(msg);
console.log(msg);
}
// ##### generic REST API calling method ##############
function callApi(path,data,parseResult=true){
var xhttp = new XMLHttpRequest();
xhttp.open("POST", pyramidURL+path, false);
xhttp.send(JSON.stringify(data));
if(parseResult){
return JSON.parse(xhttp.responseText);
}else{
return xhttp.responseText;
}
}
PyramidViewUserObject